package guo.controller;

import guo.bean.ConfiggBean;
import guo.bean.SelfBean;
import guo.util.R;
import guo.validation.idpg.InsertValidation;
import guo.validation.idpg.PutValidation;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.List;

@Controller
public class ConfiggBeanController {


    @PostMapping("/postConfig")
    @ResponseBody
    public R getUser(@Valid @RequestBody ConfiggBean configgBean){

        System.out.println(configgBean);
        return R.ok();
    }

    @RequestMapping("/validation/insert")
    @ResponseBody
    public R insertUser(@Validated({InsertValidation.class}) @RequestBody SelfBean selfBean){

        System.out.println(selfBean);
        return R.ok();
    }

    @RequestMapping("/validation/put")
    @ResponseBody
    public R puttUser(@Validated({PutValidation.class}) @RequestBody SelfBean selfBean){

        System.out.println(selfBean);
        return R.ok();
    }

}
